using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
namespace CoreData
{
    public class Customer
    {
        public long ID { get; set; }
        public string Code { get; set; }
        public string Name { get; set; }
        public string Address { get; set; }
        public string Phone { get; set; }
        public string Email { get; set; }
        public string Sex { get; set; }
        public string IndentifyNumber { get; set; }
        public string Description { get; set; }
        public bool Active { get; set; }
        public bool IsDeleted { get; set; }

        public Customer()
        {
            Code = "";
            Name = "";
            Address = "";
            Phone = "";
            Email = "";
            Sex = "";
            IndentifyNumber = "";
            Description = "";
        }

        static Customer DynamicCast<T>(object row_data, object row_header) where T : Customer
        {
            // row_data : DataRow
            // row_header : DataColumnCollection
            Customer ret = new Customer();
            DataRow dt = (DataRow)row_data;

            foreach (DataColumn column in (DataColumnCollection)row_header)
            {
                switch (column.ColumnName)
                {
                    case "ID":
                        ret.ID = ConvertObject.ToLong(dt[column]);
                        break;
                    case "Code":
                        ret.Code = ConvertObject.ToString(dt[column]);
                        break;
                    case "Name":
                        ret.Name = ConvertObject.ToString(dt[column]);
                        break;
                    case "Address":
                        ret.Address = ConvertObject.ToString(dt[column]);
                        break;
                    case "Phone":
                        ret.Phone = ConvertObject.ToString(dt[column]);
                        break;
                    case "Email":
                        ret.Email = ConvertObject.ToString(dt[column]);
                        break;
                    case "Sex":
                        ret.Sex = ConvertObject.ToString(dt[column]);
                        break;
                    case "IndentifyNumber":
                        ret.IndentifyNumber = ConvertObject.ToString(dt[column]);
                        break;
                    case "Description":
                        ret.Description = ConvertObject.ToString(dt[column]);
                        break;
                    case "Active":
                        ret.Active = ConvertObject.ToBool(dt[column]);
                        break;
                    case "IsDeleted":
                        ret.IsDeleted = ConvertObject.ToBool(dt[column]);
                        break;

                    default:
                        break;
                }
            }

            return ret;
        }

    }
}
